Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Three spec failures, all datetime-related

#34

After generating with ./script/generate authenticated member session --include-activation --rspec I'm seeing three failures when I run rake spec:models:

1) 'Member remembers me default two weeks' FAILED
expected true, got false
./spec/models/member_spec.rb:220:

2)
'Member remembers me until one week' FAILED
expected: Thu Jan 22 04:20:15 UTC 2009,
   got: Thu, 22 Jan 2009 04:20:15 UTC +00:00 (using ==)
./spec/models/member_spec.rb:211:

3)
'Member remembers me for one week' FAILED
expected true, got false
./spec/models/member_spec.rb:203:

That second one in particular looks suspiciously like a database problem to me. I tried adding :db to the remember_token_expires_at: field of the quentin: member fixture but that has no effect on the failure.

I'm on Mac OS X 10.5.6 using rails 2.2.2, sqlite3 3.4.0, rspec 1.1.12, rspec-rails 1.1.12, and sqlite-ruby 1.2.1. My test.log file is attached in case it's helpful. Line 591 is where it starts updating remember_token_expires_at.

Reported by Ben Kimball · January 14th, 2009 @ 10:43 PM

State: new
Milestone: none
Assigned to: mrflip mrflip

Activity

  1. foleyflex
    foleyflex

    Happened to me as well...a couple of workarounds: 1. Adding the :db to the remember_token_expires_at: field of the quentin: user fixture (users.yml) is VERY important. In some installs of mysql I tested, this would cause all model specs to fail (Could be version of mysql or how its configured...haven't determined).

    1. For the failure on line 211 above, I switched from using '==' to using should.eql? time. The == seems to evaluate the output, the eql? seems to compare actual time values. This is important because after storing the time value in the quentin object, it spits it back in rfc822 format on output.

    2. I've been having issues with the between? method in rspec. It seems to fail in some instances when called programatically, but when I test it in the console, it never fails...possible minor deviations in ruby acquiring system time (I'm on a Windows box). I worked around by outputting the datetime stamps as a date...testing the cookie to expire to the second wasn't that important for me.

    January 17th, 2009 @ 10:27 AM

  2. foleyflex
    foleyflex

    Wow...my comments got munged..oh well, the point it made.

    January 17th, 2009 @ 10:29 AM

  3. Ben Kimball
    Ben Kimball

    Ah, thanks foleyflex.

    The problem is definitely in the date comparison algorithm; I think between? must use '>', '<', and/or '==' internally.

    I managed to fix the test failures (in a kind of fragile way) with this:

    it 'remembers me for one week' do
      timeout = 1.week.from_now.utc
      members(:quentin).remember_me_for 1.week
      members(:quentin).remember_token.should_not be_nil
      members(:quentin).remember_token_expires_at.should_not be_nil
      members(:quentin).remember_token_expires_at.should.eql? timeout
    end
    
    

    January 17th, 2009 @ 09:12 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.